package com.ukao.pad.adapter;

import android.content.Context;
import android.graphics.Color;
import android.support.percent.PercentRelativeLayout;
import android.text.TextUtils;
import android.util.Log;
import android.widget.TextView;

import com.mcxtzhang.commonadapter.rv.CommonAdapter;
import com.mcxtzhang.commonadapter.rv.ViewHolder;
import com.ukao.pad.R;
import com.ukao.pad.bean.ClothingInformationBean;
import com.ukao.pad.listener.OnClothesItemCheckedListener;
import com.ukao.pad.utils.DateUtils;

import java.util.Date;
import java.util.List;

/**
 * Created by kefu001 on 2018/5/11.
 */

public class ClothingAnnexListAdapter extends CommonAdapter<ClothingInformationBean.AnnexListBean> {
    private  String codeNo;

    public ClothingAnnexListAdapter(Context context, List<ClothingInformationBean.AnnexListBean> datas) {
        super(context, datas, R.layout.adapter_clothing_annex_list_item);
    }
    public  void setSelectedItem(String codeNo){
        this.codeNo=codeNo;
    }

    @Override
    public void convert(ViewHolder viewHolder, ClothingInformationBean.AnnexListBean annexListBean) {
        PercentRelativeLayout percentRelativeLayout =viewHolder.getView(R.id.MyPercentLayout);
       TextView tvProductName =viewHolder.getView(R.id.product_name);
       TextView tvClothingCode=viewHolder.getView(R.id.tv_clothing_code);
       TextView tvConveyType=viewHolder.getView(R.id.tv_convey_type);
       TextView tvPassProcess =viewHolder.getView(R.id.tv_pass_process);
       TextView tvOperator=viewHolder.getView(R.id.tv_operator);
        tvProductName.setText(annexListBean.getProductName()+"");
         if(annexListBean.isChecked()){
             tvClothingCode.setText(codeNo);
             percentRelativeLayout.setBackgroundColor(Color.parseColor("#564013"));
         }else {
             tvClothingCode.setText(annexListBean.getScanCode());
             percentRelativeLayout.setBackgroundColor(Color.parseColor("#222222"));
         }
        if(annexListBean.getTranNum()!=0){
            tvConveyType.setText("输"+annexListBean.getTranNum());
        }else {
            tvConveyType.setText("");
        }
        if(!TextUtils.isEmpty(annexListBean.getStatusText())){
            if(annexListBean.getStatusText().trim().equals("已洗完")){
                tvPassProcess.setTextColor(mContext.getResources().getColor(R.color.green));
            }else if(annexListBean.getStatusText().trim().equals("洗涤中")){
                tvPassProcess.setTextColor(mContext.getResources().getColor(R.color.warm_red));
            }else {
                tvPassProcess.setTextColor(mContext.getResources().getColor(R.color.white));
            }
            Date d1=new Date(annexListBean.getStatusTime());
            String  time= DateUtils.formatDataTime(d1);
            tvPassProcess.setText(annexListBean.getStatusText()+"\n"+time);
        }else {
            tvPassProcess.setText("");
            tvPassProcess.setTextColor(mContext.getResources().getColor(R.color.white));
        }
        if(!TextUtils.isEmpty(annexListBean.getStatusWorkName())){
            tvOperator.setText(annexListBean.getStatusWorkName());
        }else {
            tvOperator.setText("");
        }
    }
}
